import request from '@/utils/request'
const UpmsRolePermissionService = {
  state: {},

  mutations: {},

  actions: {
    // 获取指定角色下的权限
    getPermissionByRoleId({ commit }, roleId) {
      return new Promise((resolve, reject) => {
        request.get('rolePermission/getPermissionByRoleId', { roleId: roleId }).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },

    // 保存分配的权限
    rolePermissionSave({ commit }, params) {
      return new Promise((resolve, reject) => {
        request.post('rolePermission/rolePermissionSave/' + params.roleId, params.permissionIdList).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },

    // 删除分配的权限
    rolePermissionRemove({ commit }, params) {
      return new Promise((resolve, reject) => {
        request.post('rolePermission/rolePermissionRemove/' + params.roleId, params.permissionIdList).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    }
  }
}

export default UpmsRolePermissionService
